﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TranslatorView.xaml.cs" company="WordSteps.com">
//   All rights reserved
// </copyright>
// <summary>
//   Interaction logic for TranslatorView.xaml
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System.Windows.Data;
using System.Windows.Input;

namespace RapidDict.Modules.Translator.Views
{
    using System.Windows.Controls;

    /// <summary>
    /// Interaction logic for TranslatorView.xaml
    /// </summary>
    public partial class TranslatorView
    {
        public TranslatorView(TranslationViewModel model)
        {
            InitializeComponent();

            Loaded += (s, e) =>
                               {
                                   DataContext = model;
                               };
        }

        private void WordKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                // When you set the UpdateSourceTrigger value to Explicit, 
                // the source value only changes when the application calls the UpdateSource method.

                BindingExpression be = tbxWord.GetBindingExpression(TextBox.TextProperty);
                if (be != null) be.UpdateSource();
            }
        }
    }
}